<template>
	<view>
		<div style="height: 44px;background-color: #fff;width:100%"></div>
		<up-navbar :safeAreaInsetTop="false" title="添加自营产品"   style="color: #4095E5;"  :fixed="false"   rightText="完成" @rightClick="confirmProduct"
			@leftClick="uni.navigateBack()"  border="true" />

		<div class="cell">
			<div class="tit">产品名称</div>
			<div class="cell_content">
				<up-input placeholder="请输入" border="false"  disabledColor="#fff"
					v-model="productName"></up-input>
			</div>
		</div>
			<div class="cell">
			<div class="tit">门店标价</div>
			<div class="cell_content">
				<up-input placeholder="请输入" border="false" disabledColor="#fff"
					v-model="storeprice"></up-input>
			</div>
		</div>
			<div class="cell">
			<div class="tit">门店业绩</div>
			<div class="cell_content">
				<up-input placeholder="请输入" border="false" disabledColor="#fff"
					v-model="storeperformance"></up-input>
			</div>
		</div>
	</view>
</template>

<script setup>
import {ref} from 'vue'
import { getUserProductList, addProductList } from '../../utils/product'

const productName = ref('')
const storeprice = ref('')
const storeperformance = ref('')

const confirmProduct = async () => {
  
 console.log(productName.value ,storeprice.value ,  storeperformance.value)

	if (productName.value == '' || storeprice.value == '' || storeperformance.value == '') {
		uni.showToast({
			title: '请填写完整信息',
			icon: 'none',
			duration: 2000
		})
		return
	}

	try {
		const res = await addProductList({
			businessId: uni.getStorageSync('businessId'),
			type: 0,
			productName: productName.value,
			busPrice: storeprice.value,
			busAchievement: storeperformance.value
		})
		console.log(res)
		uni.showToast({
			title: '添加成功',
			icon: 'success',
			duration: 2000
		})
		uni.navigateTo({
			url: '/pages/product/product'
		})
	} catch (e) {

	}
}


</script>

<style lang="scss">
	page {
		overflow-x: hidden;
	}
	
	/* 隐藏横向滚动条 */
	::-webkit-scrollbar {
		display: none;
	}
	
	* {
		-ms-overflow-style: none;
		scrollbar-width: none;
	}
.cell {
	width: 100%;
	padding: 20rpx;
	display: flex;
	align-items: center;
	border-bottom: 1px solid rgba(239, 239, 239, 1);
   box-sizing: border-box;
	.tit1 {
		color: rgb(16, 16, 16);
		font-size: 32rpx;
		text-align: left;
		font-family: PingFangSC-regular;
		position: relative;
		padding-left: 24rpx;
	}

	.tit {
		color: rgb(16, 16, 16);
		font-size: 32rpx;
		text-align: left;
		font-family: PingFangSC-regular;
		position: relative;
		padding-left: 24rpx;

		&:before {
			content: '*';
			position: absolute;
			left: 0;
			top: 60%;
			transform: translateY(-50%);
			color: #ff0000;
			font-size: 32rpx;
		}
	}

	.cell_content {
		width: 100%;
		flex: 1;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-left: 20rpx;
		padding-right: 40rpx;
		font-size: 32rpx;
	}
}
</style>
